Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.ProduclicensesForm = Ext.extend(Divo.Base.EditForm, {
  fields : new Ext.util.MixedCollection(),
  dataRecordMeta : Ext.data.Record.create([{
        name : "_p_record_status",
        type : "string"
      }, {
        name : "id",
        type : "float"
      }, {
        name : "supplierId",
        type : "float"
      }, {
        name : "supplier",
        type : "string"
      }, {
        name : "produceId",
        type : "float"
      }, {
        name : "produce",
        type : "string"
      }, {
        name : "produceNo",
        type : "string"
      }, {
        name : "registerAddress",
        type : "string"
      }, {
        name : "produceAddress",
        type : "string"
      }, {
        name : "person",
        type : "string"
      }, {
        name : "companyPerson",
        type : "string"
      }, {
        name : "businessRange",
        type : "string"
      }, {
        name : "licensDate",
        type : "string"
      }, {
        name : "endDate",
        type : "string"
      }, {
        name : "licensesOrg",
        type : "string"
      }]),
  initComponent : function() {
    var me = this;
    var tn = 1;

    this.fields.add("_p_record_status", new Ext.form.Hidden({
              name : "_p_record_status"
            }));
    this.fields.add("id", new Ext.form.Hidden({
              name : "id",
              dataIndex : "id",
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("supplierId", new Ext.form.Hidden({
              name : "supplierId",
              dataIndex : "supplierId",
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("produceId", new Ext.form.Hidden({
              name : "produceId",
              dataIndex : "produceId",
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("produceNo", new app.base.TextField({
              name : "produceNo",
              dataIndex : "produceNo",
              fieldLabel : "生产（经营）编号",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("registerAddress", new app.base.TextField({
              name : "registerAddress",
              dataIndex : "registerAddress",
              fieldLabel : "注册地址",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("produceAddress", new app.base.TextField({
              name : "produceAddress",
              dataIndex : "produceAddress",
              fieldLabel : "生产（经营）地址",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("person", new app.base.TextField({
              name : "person",
              dataIndex : "person",
              fieldLabel : "法人代表",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("companyPerson", new app.base.TextField({
              name : "companyPerson",
              dataIndex : "companyPerson",
              fieldLabel : "企业负责人",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("companyType", new app.base.TextField({
              name : "companyType",
              dataIndex : "companyType",
              fieldLabel : "公司类型",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("businessRange", new app.base.TextField({
              name : "businessRange",
              dataIndex : "businessRange",
              fieldLabel : "生产（经营）范围",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("licensDate", new app.base.DateField({
              name : "licensDate",
              dataIndex : "licensDate",
              format : 'Y.m.d',
              fieldLabel : "有效期至",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              editable : true,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("endDate", new app.base.DateField({
              name : "endDate",
              dataIndex : "endDate",
              fieldLabel : "有效期至",
              allowBlank : false,
              format : 'Y.m.d',
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("licensesOrg", new app.base.TextField({
              name : "licensesOrg",
              dataIndex : "licensesOrg",
              fieldLabel : "发证机关",
              allowBlank : false,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    var recordDef = Ext.data.Record.create([{
          name : "id",
          type : "float"
        }, {
          name : "name",
          type : "string"
        }]);
    var storeDs = new Ext.data.Store({
          proxy : new Ext.data.HttpProxy({
                url : 'high_value_material/query_s'
              }),
          reader : new Ext.data.JsonReader({
                root : 'rows',
                totalProperty : 'totalCount',
                id : 'id'
              }, recordDef)
        });
    this.fields.add("supplier", new app.base.TextField({
              name : "supplier",
              dataIndex : "supplier",
              fieldLabel : "供应商",
              allowBlank : false,
              readOnly : true,
              labelSeparator : ":*",
              tabIndex : tn++,
              width : 150,
              insert_allowed : true,
              update_allowed : true
            }));
    this.fields.add("produce", new app.base.ComboBox({
              id : 'combo-produce2',
              name : "produce",
              dataIndex : "produce",
              fieldLabel : '选择生产商',
              store : storeDs,
              displayField : 'name',
              valueField : 'id',
              forceSelection : true,
              mode : 'remote',
              triggerAction : 'all',
              editable : false,
              allowBlank : false,
              labelSeparator : ":*",
              selectOnFocus : true,
              width : 150,
              insert_allowed : true,
              update_allowed : true,
              onSelect : function(record) {
                var data = record.data;
                this.setValue(data.name);
                me.setFieldValue("produceId", data.id);
                this.onTriggerClick();
              }
            }));
    Ext.apply(this, {
          items : [this.fields.get("_p_record_status"), {
            layout : "form",
            columnWidth : 1,
            labelAlign : "right",
            labelWidth : 100,
            items : [this.fields.get("id"), this.fields.get("supplierId"),
                this.fields.get("produceId"), this.fields.get("supplier"),
                this.fields.get("produce"), this.fields.get("produceNo"),
                this.fields.get("registerAddress"),
                this.fields.get("produceAddress"), this.fields.get("person"),
                this.fields.get("companyPerson"),
                this.fields.get("businessRange"),
                this.fields.get("licensDate"), this.fields.get("endDate"),
                this.fields.get("licensesOrg")]
          }],
          border : false,
          frame : true,
          firstFocusFieldName : "produce"
        });

    Divo.app.ProduclicensesForm.superclass.initComponent.apply(this, arguments);
  }

  ,
  onRender : function() {
    Divo.app.ProduclicensesForm.superclass.onRender.apply(this, arguments);
  },
  newDataRecord : function() {
    return new this.dataRecordMeta({
          _p_record_status : "insert",
          id : "",
          name : "",
          sId : "",
          state : ""
        });
  }

});
Ext.reg("Divo.app.ProduclicensesForm", Divo.app.ProduclicensesForm);